package com.sky.wsp.mybatis.plus.config;

import com.sky.wsp.mybatis.plus.interceptor.MyInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * MVC拦截器配置
 *
 * @author wangshaopeng@talkweb.com.cn
 * @Date 2023-01-11
 */
@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getMyInterceptor())
                .addPathPatterns("/**")
                .order(-10);
    }

    /**
     * 自定义请求头拦截器
     */
    @Bean
    public MyInterceptor getMyInterceptor() {
        return new MyInterceptor();
    }

}
